/* main.c */
#include "app_inc.h"

char bleXferTxTestBuf[50];

int main(void)
{
    BSP_InitSystem();
    BSP_InitStdioLPUART(115200U);

    WS2812B_Init();
    WS2812B_DoUpdateColorRight(0x00);
    WS2812B_DoUpdateColorLeft(0x00);

    printf("\r\n\r\nBleXfer_EDMA Demo.\r\n");
    printf("Compiled on %s, %s\r\n\r\n", __DATE__, __TIME__);

    printf("Initializing ...");

    BleXfer_Init();

    printf("Done.\r\n");

    while (1)
    {
        switch (BleXfer_GetRunCmdFromCmdFifo())
        {
            case 'A':
                printf("A");
                /* 测试回发 */
                WS2812B_DoUpdateColorLeft(0x0F);
                sprintf(bleXferTxTestBuf, "{A%d:%d:%d:%d}$",50,30,80,100);
                BleXfer_Send((uint8_t *)bleXferTxTestBuf, strlen(bleXferTxTestBuf), NULL);
                break;
            case 'B':
                printf("B");
                break;
            case 'C':
                printf("C");
                break;
            case 'D':
                printf("D");
                break;
            case 'E':
                printf("E");
                break;
            case 'F':
                printf("F");
                break;
            case 'G':
                printf("G");
                break;
            case 'H':
                printf("H");
            case 'Z':
                printf("Z");
                /* 测试回发 */
                WS2812B_DoUpdateColorLeft(0x00);
                sprintf(bleXferTxTestBuf, "{A%d:%d:%d:%d}$",30,50,20,10);
                BleXfer_Send((uint8_t *)bleXferTxTestBuf, strlen(bleXferTxTestBuf), NULL);
                break;
            default: /* 保持现状 */
                break;
        }
    }
}

/* EOF. */

